/**
 * Created by zhangbin on 16/2/26.
 */
/**
 * Created by zhangbin on 16/2/22.
 */
function openMenuTab(node){
    if ($('#tabs').tabs('exists',node.text)){
        $('#tabs').tabs('select', node.text);
    } else {
        $('#tabs').tabs('add',{
            title:node.text,
            closable:true,
            content:'<iframe scrolling="yes" frameborder="0"  src="'+node.attributes.url+'" style="width:100%;height:100%;"></iframe>',
        });
    }
}

$(function(){
    $.getJSON("/sec/menuTree",function(data){
        $('#menutree').tree({
            data : data
        });
    });
    $('#menutree').tree({
        onClick : function(node){
            if(node.children.length==0) {
                openMenuTab(node);
            }
        },
    });
});
